package com.xiaow.android.ebook.app.ui;

import java.util.Timer;
import java.util.TimerTask;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.xiaow.android.ebook.Initializer;
import com.xiaow.android.ebook.mvc.common.Request;
import com.xiaow.android.ebook.mvc.ui.BaseActivity;

public class SplashActivity extends BaseActivity {
	private static final String TAG = "App-View";
	private Handler maLauncher = new Handler() {
		public void handleMessage(Message msg) {
			launchMainActivity();
		}
	};

	
	protected View createContentView() {
		TextView tv = new TextView(this);
		tv.setTextSize(40);
		tv.setGravity(Gravity.CENTER);
		tv.setText("Splash");

		return tv;
	}

	
	protected void onBeforeCreate(Bundle savedInstanceState) {
		Initializer.ensureInitialized();
	}

	
	protected void onAfterCreate(Bundle savedInstanceState) {
		TimerTask task = new TimerTask() {
			
			public void run() {
				Log.i(TAG, "SplashActivity//task//run");
				maLauncher.sendEmptyMessage(100);
			}
		};

		new Timer().schedule(task, 2000);
	}

	private void launchMainActivity() {
		Request request = new Request();
		request.setTag("splash-shared");
		request.setActivityID(Initializer.Main_id);
		go(Initializer.IdentityCommand_id, request, false, true, true);
	}
}
